package com.example.demo;

import com.example.demo.entity.TimingDataEntity;
import com.example.demo.entity.TimingDataEntityCacheData;
import com.example.demo.repository.TimingDataEntityRepository;
import com.timing.finder.framework.HandleType;
import com.timing.finder.framework.TimeSeriesDataFinder;
import com.timing.finder.framework.TimingFinderApplication;
import com.timing.finder.framework.TimingFinderBootstrap;
import com.timing.finder.util.processor.SpringStartProcessor;
import org.springframework.stereotype.Component;

/**
 * @author JingGe(* ^ ▽ ^ *)
 * @date 2023-07-17 15:30
 * @email 1158055613@qq.com
 */
@Component
public class TimingDBRunner implements SpringStartProcessor {
    @Override
    public void onStart() {
        TimingFinderApplication<TimingDataEntity> application = new TimingFinderBootstrap<>(new TimingDataEntityRepository(), new HandleType(TimingDataEntity.class, TimingDataEntityCacheData.class))
                .setConfigSuffix("demo")
                .build()
                .run();
        //可以从应用中获取Finder
        TimeSeriesDataFinder<TimingDataEntity> finder = application.getTimeSeriesDataFinder();
        //也可以通过配置文件新建Finder
        TimeSeriesDataFinder<TimingDataEntity> finder2 = new TimeSeriesDataFinder<>("demo");
    }
}
